<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="embroot.css">
<TITLE>
Constructing ECLiPSe terms in C++
</TITLE>
</HEAD>
<BODY >
<A HREF="embroot065.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="embroot067.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc129">B.1</A>&nbsp;&nbsp;Constructing ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> terms in C++</H2><UL>
<LI><A HREF="embroot066.html#toc68">Class EC_atom and EC_functor</A>
<LI><A HREF="embroot066.html#toc69">Class EC_word</A>
</UL>

<A NAME="toc68"></A>
<H3 CLASS="subsection"><A NAME="htoc130">B.1.1</A>&nbsp;&nbsp;Class EC_atom and EC_functor</H3>
The ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> dictionary provides unique identifiers for
name/arity pairs. EC_atoms are dictionary identifiers with zero arity,
EC_functors are dictionary identifiers with non-zero arity.
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<B>EC_atom(char*)</B><DD CLASS="dd-description"><BR>
	looks up or enters the given string into the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>
	dictionary and returns a unique atom identifier for it.<BR>
<BR>
<DT CLASS="dt-description"><B>char* EC_atom::name()</B><DD CLASS="dd-description"><BR>
	returns the name string of the given atom identifier.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_functor(char*,int)</B><DD CLASS="dd-description"><BR>
	looks up or enters the given string with arity into the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>
	dictionary and returns a unique functor identifier for it.<BR>
<BR>
<DT CLASS="dt-description"><B>char* EC_functor::name()</B><DD CLASS="dd-description"><BR>
	returns the name string of the given functor identifier.<BR>
<BR>
<DT CLASS="dt-description"><B>int EC_functor::arity()</B><DD CLASS="dd-description"><BR>
	returns the arity of the given functor identifier.
</DL>
<A NAME="toc69"></A>
<H3 CLASS="subsection"><A NAME="htoc131">B.1.2</A>&nbsp;&nbsp;Class EC_word</H3>
The EC_word is the basic type that all ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> data structures are
built from (because within ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> typing is dynamic).
The following are the functions for constructing ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> terms from
the fundamental C++ types:
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<B>EC_word(const char *)</B><DD CLASS="dd-description"><BR>
	converts a C++ string to an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> string. The string is copied.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word(const int, const char *)</B><DD CLASS="dd-description"><BR>
	converts a C++ string of given length to an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> string.
	The string is copied and can contain NUL bytes.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word(const EC_atom)</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> atom from an atom identifier.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word(const long)</B><DD CLASS="dd-description"><BR>
	converts a C++ long to an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> integer.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word(const double)</B><DD CLASS="dd-description"><BR>
	converts a C++ double to an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> double float.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word(const EC_ref&amp;)</B><DD CLASS="dd-description"><BR>
	retrieves the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> term referenced by the EC_ref (see below).<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word term(const EC_functor,const EC_word args[&nbsp;])</B><DD CLASS="dd-description"><BR>
<DT CLASS="dt-description"><B>EC_word term(const EC_functor,const EC_word arg1, ...)</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> compound term from the given components.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word list(const EC_word hd, const EC_word tl)</B><DD CLASS="dd-description"><BR>
	Construct a single ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> list cell.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word list(int n, const long*)</B><DD CLASS="dd-description"><BR>
	Construct an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> list of length n from an array of long integers.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word list(int n, const char*)</B><DD CLASS="dd-description"><BR>
	Construct an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> list of length n from an array of chars.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word list(int n, const double*)</B><DD CLASS="dd-description"><BR>
	Construct an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> list of length n from an array of doubles.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word array(int, const double*)</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> array (a structure with functor [&nbsp;]of
	appropriate arity) of doubles from the given C++ array.
	The data is copied.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word matrix(int rows, int cols, const double*)</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> array (size rows) of arrays (size cols) of doubles
	from the given C++ array. The data is copied.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word handle(const t_ext_type *cl, const t_ext_ptr data)</B><DD CLASS="dd-description"><BR>
	Construct an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> handle for external data, attaching the
	given method table.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word newvar()</B><DD CLASS="dd-description"><BR>
	Construct a fresh ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> variable.<BR>
<BR>
<DT CLASS="dt-description"><B>EC_word nil()</B><DD CLASS="dd-description"><BR>
	Construct the empty list [&nbsp;].
</DL>
<HR>
<A HREF="embroot065.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="embroot067.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
